package utils

import (
	"os"
	"syscall"
	"unsafe"
	"strings"
)

func SetWinsize(f *os.File, w, h int) { //调整term窗口大小使用 不需要动
	syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), uintptr(syscall.TIOCSWINSZ),
		uintptr(unsafe.Pointer(&struct{ h, w, x, y uint16 }{uint16(h), uint16(w), 0, 0})))
}

func Chop(addr string) string {
	if strings.Contains(addr, ":") {
		s := strings.Split(addr, ":")
		return s[0]
	}
	return addr
}
